package transaction;

import javax.annotation.Resource;

import model.SimpleUser;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import persistance.UserDAO;

@Service("userService")
public class UserService {

	@Resource(name="logdao")
	private LogDAO logdao;
	public LogDAO getLogdao() {
		return logdao;
	}

	public void setLogdao(LogDAO logdao) {
		this.logdao = logdao;
	}

	public UserDAO getUserdao() {
		return userdao;
	}

	public void setUserdao(UserDAO userdao) {
		this.userdao = userdao;
	}

	@Resource(name="userdao")
	private UserDAO userdao;
	
	@Transactional
	public void addUserService()
	{
		SimpleUser user=new SimpleUser("lcx-trans",25);
		userdao.insert(user);
		logdao.log();
	}
	
	@Transactional(rollbackFor=Exception.class)
	public void addUserServiceException() throws Exception
	{
		SimpleUser user=new SimpleUser("lcxxxx222222",25);
		userdao.insert(user);
		logdao.logException();
	}
	
}
